<template>
	<view class="childpage">
		<view class="userBox">
			<view class="listItem" v-for="(i,index) in list" :key="index">
				<view class="item">
					<text>转账金额：</text>
					<text v-if="i.type==1" style="color:#ff537b;font-weight: bold;">-{{i.money}}</text>
					<text v-else style="color:#63BE72;font-weight: bold;">+{{i.money}}</text>
				</view>
				<view class="item">
					<text>操作：</text>
					<text style="color:#ff537b;font-weight: bold;">{{i.from_user_name}}</text>
					<text style="margin: 0 10upx;">转给</text>
					<text style="color:#ff537b;font-weight: bold;">{{i.to_user_name}}</text>
				</view>
				<view class="item">
					<view>时间：<text style="color:#666;">{{i.create_at}}</text></view>
				</view>
			</view>
			<view class="hasmore">{{hasmore?'加载中':'没有更多了'}}</view>
		</view>

	</view>
</template>

<script>
	import {
		get,
		formatDate
	} from "@/utils/post";
	export default {
		data() {
			return {
				list: [],
				hasmore: false,
				page: 1,
				limit: 20,
				status_name: ''
			}
		},
		onLoad(op) {
			this.btype = op.type
			this.init()
		},
		filters: {
			keepFour(num) {
				return num.substring(num.length - 4)
			},
			formatdate(time) {
				return formatDate(time * 1000, 'yyyy-MM-dd hh:mm')
			}
		},
		methods: {
			init() {
				var data = {
					page: this.page,
					limit: this.btype,
					b_type: this.btype
				}
				this.$request({
					url: this.$api.wallet.transfer_list,
					method: 'post',
					data: data
				}).then(info => {
					this.page++
					if (info.code == 0) {
						this.list = this.list.concat(info.data)
						this.hasmore = info.data.length == this.limit
					}
				}).catch(info => {})
			}
		},
		onReachBottom() {
			if (this.hasmore) {
				this.init()
			}
		}
	}
</script>

<style scoped lang="less">
	.listItem {
		width: 100%;
		border-bottom: 1px solid #707070;
		margin-bottom: 20upx;
		padding-bottom: 20upx;
		font-size: 28upx;
		color: #000;
	}

	.item {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 50upx;
	}

	.cmoney {
		color: #ff537b;
		border: 1px solid #ff537b;
	}

	.userBox {
		padding: 20upx 20upx;
		box-sizing: border-box;
		background: #fff;
		box-shadow: 0px 0px 5px #aaa;
		width: 700upx;
		border-radius: 10upx;
		margin-top: 30upx;
		margin-bottom: 50upx;
	}

	.childpage {
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-top: 1px;
	}
</style>
